import os

"""
开发环境配置
"""
dev_config = {
    'DEBUG': True,
    'BIND': '0.0.0.0:5151',
    'SEND_TASK_URL': 'http://127.0.0.1:5002',
    'SQLALCHEMY_DATABASE_URI': 'mysql+pymysql://root:Yydj_2023f@rm-2vc17il54x88franj.mysql.cn-chengdu.rds.aliyuncs'
                               '.com:3306/analysis_test',
    'SQLALCHEMY_ENGINE_OPTIONS': {
        'pool_size': 3,
        'max_overflow': 5,
        'pool_timeout': 30,
    },
    'REDIS_CONFIG': {
        'host': 'r-2vcus8exwk11f8jhhp.redis.cn-chengdu.rds.aliyuncs.com',  # 专有网络
        # 'host': '127.0.0.1',  # 本地配置
        'port': 6379,
        'password': 'Yydj@!#qaz2023',
        'db': '0',
        'expire': 60 * 60,
    },
}

"""
线上环境配置
"""
prod_config = {
    'DEBUG': False,
    'BIND': '0.0.0.0:5000',
    'SEND_TASK_URL': 'http://127.0.0.1:5003',
    'SQLALCHEMY_DATABASE_URI': 'mysql+pymysql://root:Yydj_2023f@rm-2vc17il54x88franj.mysql.cn-chengdu.rds.aliyuncs'
                               '.com:3306/analysis',
    'SQLALCHEMY_ENGINE_OPTIONS': {
        'pool_size': 20,
        'max_overflow': 1000,
        'pool_timeout': 30,
    },
    'REDIS_CONFIG': {
        'host': 'r-2vcus8exwk11f8jhhp.redis.cn-chengdu.rds.aliyuncs.com',  # 专有网络
        # 'host': 'r-2vcus8exwk11f8jhhppd.redis.cn-chengdu.rds.aliyuncs.com',  # 公网
        'port': 6379,
        'password': 'Yydj@!#qaz2023',
        'db': '1',
        'expire': 60 * 60,
    },
}

"""
    配置文件映射
"""
CONFIG_NAME_MAPPER = {
    'local': dev_config,
    'dev': dev_config,
    'prod': prod_config,
    # 'test': dev_config
}


def config_mapping() -> dict:
    env_flask_config_name = os.getenv('ANALYSIS_CONFIG')
    config_mapper_name = env_flask_config_name or 'local'
    return CONFIG_NAME_MAPPER[config_mapper_name]
